@extends('layouts.admin')

@section('content')
<div class="page-header">
	<h2>User - 
		<small>
		@if($method == 'post')
			Add a new user
		@elseif($method == 'delete')
			Delete {{$user->first_name}} user ?
		@else
			Edit {{$user->first_name}} user
		@endif
		</small>
	</h2>
</div>
@if ($message = $errors->first('message'))
<div class="row">
	<div class="col-lg-12">
		<div class="alert alert-danger alert-block">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<h4>Unsuccess</h4>
			{{{ $message }}}
		</div>
	</div>
</div>
@endif

<div class="row">
	<div class="col-lg-12">
		{{Form::model($user, array('method' => $method, 'url'=>'users/'.$user->id, 'class' => 'form-horizontal'))}}
		@unless($method == 'delete')
			@if($method == 'post')
				<!-- user name -->
				<div class="form-group {{{ $errors->has('username') ? ' has-error' : '' }}}">
					<div class="col-sm-4">
						{{ Form::label('username', 'Username', array('class' => 'control-label')) }}
						{{ Form::text('username', Input::old('username'), array('class' => 'form-control')) }}
					</div>
				</div>

				<!-- Password -->
				<div class="form-group {{{ $errors->has('password') ? ' has-error' : '' }}}">
					<div class="col-sm-4">
						{{ Form::label('password', 'Password', array('class' => 'control-label')) }}
						{{ Form::password('password', array('class' => 'form-control')) }}
					</div>
				</div>
				
				<!-- Confirm Password -->
				<div class="form-group {{{ $errors->has('password') ? ' has-error' : '' }}}">
					<div class="col-sm-4">
						{{ Form::label('confirm_password', 'Confirm Password ', array('class' => 'control-label')) }}
						{{ Form::password('confirm_password', array('class' => 'form-control')) }}
					</div>
				</div>
			@endif
			<div class="form-group {{{ $errors->has('first_name') ? ' has-error' : '' }}}">
				<div class="col-sm-4">
					{{ Form::label('first_name', 'First name', array('class' => 'control-label')) }}
					{{ Form::text('first_name', Input::old('first_name'), array('class' => 'form-control')) }}
				</div>
			</div>
			
			<div class="form-group {{{ $errors->has('last_name') ? ' has-error' : '' }}}">
				<div class="col-sm-4">
					{{ Form::label('last_name', 'Last name', array('class' => 'control-label')) }}
					{{ Form::text('last_name', Input::old('last_name'), array('class' => 'form-control')) }}
				</div>
			</div>
			
			<div class="form-group {{{ $errors->has('email') ? ' has-error' : '' }}}">
				<div class="col-sm-4">
					{{ Form::label('email', 'E-mail', array('class' => 'control-label')) }}
					{{ Form::text('email', Input::old('email'), array('class' => 'form-control')) }}
				</div>
			</div>
				
			<div class="form-group {{{ $errors->has('role_id') ? ' has-error' : '' }}}">
				<div class="col-sm-4">
					{{ Form::label('role_id', 'Role', array('class' => 'control-label')) }}
					{{ Form::select('role_id', $role_options, Input::old('role_id'), array('class' => 'form-control')) }}
				</div>
			</div>
			
			<div class="form-group {{{ $errors->has('department_id') ? ' has-error' : '' }}}">
				<div class="col-sm-4">
					{{ Form::label('department_id', 'Depertment', array('class' => 'control-label')) }}
					{{ Form::select('department_id', $department_options, Input::old('department_id'), array('class' => 'form-control')) }}
				</div>
			</div>
			
			<div class="form-group">
				<div class="col-sm-4">
					{{Form::submit("Save", array("class"=>"btn btn-success"))}}
					<a href="{{url('users')}}" class="btn btn-default">
						Cancel
					</a>
				</div>
			</div>
		@else
			<div class="form-group">
				<div class="col-sm-4">
					{{Form::submit("Delete", array("class"=>"btn btn-success"))}}
					<a href="{{url('users')}}" class="btn btn-default">
						Cancel
					</a>
				</div>
			</div>
		@endif
		{{Form::close()}}
	</div>
</div>
@stop

